﻿@model PerformanceAssessment.Models.Assessment

@{
    ViewBag.Title = "Details";
}
@using PerformanceAssessment.Models;
<style>
    input[type="submit"], input[type="button"]
    {
        font: inherit;
    }
</style>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#dialog-message").dialog({
            modal: true,
            autoOpen: false,
            buttons: {
                Ok: function () {
                    $(this).dialog("close");
                }
            }
        });
    });

    function submitAssessment() {
        $.ajax({
            type: "POST",
            url: '@Url.Action("Validate")',
            datatype: "json",
            data: { assessmentId: '@Model.ID' },
            success: function (data) {
                if (data.valid == true)
                    window.location.href = '@Url.Action("Accept", new { assessmentId = Model.ID })';
                else {
                    $("#errorMessage").text(data.error);
                    $("#dialog-message").dialog("open");
                }
            }
        });
    }
</script>

<div id="dialog-message" title="Submit Error">
	<p>
		<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 50px 0;"></span>
		<span id="errorMessage" ></span>
	</p>
</div>

<h2>
    Assessment</h2>
    <fieldset>
        <div class="display-label">
            Review Period</div>
        <div class="display-field">
            From: @Html.Label("FromDate", Model.AssessmentPeriod.FromDate.ToShortDateString()) To: @Html.Label("ToDate", Model.AssessmentPeriod.ToDate.ToShortDateString())
        </div>
        <div class="display-label">
            Employee</div>
        <div class="display-field">
            @Html.Label(string.Format("{0} {1} {2}", Model.Employee.FirstName, Model.Employee.FirstLastName, Model.Employee.SecondLastName))
        </div>
        <div class="display-label">
            Manager</div>
        <div class="display-field">
            @Html.Label(string.Format("{0} {1}", Model.Manager.FirstName, Model.Manager.LastName))
        </div>
        <div class="display-label">
            Employee Comments</div>
        <div class="display-field">
            @Html.DisplayFor(model => model.EmployeeComments)
        </div>
        <div class="display-label">
            Manager Comments</div>
        <div class="display-field">
            @Html.DisplayFor(model => model.ManagerComments)
        </div>
        <div class="display-label">
            Current Status</div>
        <div class="display-field" style="color:Blue;font-weight:bold;">
            @Html.Label(Assessment.GetStatusName((AssessmentStatus)Model.IdAssessmentStatus))
        </div>
    </fieldset>
    
    
    <div>
        <input type="button" name="btnSkills" value="Skills Assessment" onclick="window.location.href = '@Url.Action("Edit", "SkillAssessments", new { assessmentId = Model.ID, order = 0 })';"/>
        <input type="button" name="btnComments" value="Assessment Comments" onclick="window.location.href = '@Url.Action("Edit", new { assessmentId = Model.ID })';"/>
        <input type="button" name="btnGoals" value="Goals and Objectives" onclick="window.location.href = '@Url.Action("Index", "Goals", new { assessmentId = Model.ID })';"/>
        @if (Model.EditionAllowed(ViewBag.userType, UserType.Employee))
        {
            <input type="button" name="btnAccept" value="Submit Auto Evaluation" onclick="submitAssessment()" />
        }
        @if (Model.EditionAllowed(ViewBag.userType, UserType.Manager))
        {
            <input type="button" name="btnAccept" value="Submit Employee Evaluation" onclick="submitAssessment()" />
            <input type="button" name="btnSetMeeting" value="Schedule a Meeting" onclick="window.location.href = '@Url.Action("Meeting", new { assessmentId = Model.ID })';"/>
        }
        @if (Model.EditionAllowed(ViewBag.userType, UserType.Administrator))
        {
            <input type="button" name="btnAccept" value="Accept Evaluation" onclick="window.location.href = '@Url.Action("Accept", new { assessmentId = Model.ID })';"/>
            <input type="button" name="btnReject" value="Reject Evaluation" onclick="window.location.href = '@Url.Action("Reject", new { assessmentId = Model.ID })';"/>
        }
    </div>
   
<p>
    
    @Html.ActionLink("Back to List", "Index")
</p>
